<template>
  <rm-layout-top splitcolor="white" :splitwidth=5 :fixsize=100>
    <template v-slot:fix>
      <div style="height:100px;border:1px solid #CCC">
        <table class="tableclass">
          <tr v-if="isbis">
            <td>报告单元</td>
            <td>
              <rm-ddl-rptunit prgno="LIS110" v-model="searchObj.rptunitid" width="200px"
                @change="rptunitChange"></rm-ddl-rptunit>
            </td>
            <td>快速查找</td>
            <td>
              <el-input placeholder="项目代码|名称|缩写|拼音码|外部代码" size="small" style="width:210px;" v-model="searchObj.keystr"
                @keyup.enter.native="MainTable_Rfresh()" clearable>
              </el-input>
            </td>
            <td>
              <el-radio-group v-model="searchObj.stopflag">
                <el-radio :label="0" selected @change="MainTable_Rfresh()" size="mini">全部</el-radio>
                <el-radio :label="1" @change="MainTable_Rfresh()" size="mini">停用</el-radio>
                <el-radio :label="2" @change="MainTable_Rfresh()" size="mini">在用</el-radio>
              </el-radio-group>
            </td>
            <td></td>
            <td style="align:right">
            </td>
          </tr>
          <tr v-if="!isbis">
            <td>项目类别</td>
            <td>
              <rm-ddl-rptitemclass @change="rptitemclassChange" v-model="searchObj.itemclasscode" authflag="1"
                width="210px"></rm-ddl-rptitemclass>
            </td>
            <td>报告单元</td>
            <td>
              <rm-ddl-rptunit prgno="LIS110" v-model="searchObj.rptunitid" width="200px"
                @change="rptunitChange"></rm-ddl-rptunit>
            </td>
            <td>项目类型</td>
            <td>
              <el-select @change="germflagChange" v-model="searchObj.germflag" placeholder="请选择" style="width:200px">
                <el-option key="0" label="普通项目" value="0"></el-option>
                <el-option key="1" label="培养阴性结果" value="1"></el-option>
                <el-option key="5" label="培养阴性过程" value="5"></el-option>
                <el-option key="2" label="致病菌" value="2"></el-option>
                <el-option key="3" label="正常菌种" value="3"></el-option>
                <el-option key="4" label="涂片结果" value="4"></el-option>
                <el-option key="6" label="基因项目" value="6"></el-option>
              </el-select>
            </td>
            <td></td>
            <td style="align:right">
            </td>
          </tr>
          <tr v-if="!isbis">
            <td>快速查找</td>
            <td>
              <el-input placeholder="项目代码|名称|缩写|拼音码|外部代码" size="small" style="max-width:210px;" v-model="searchObj.keystr"
                @keyup.enter.native="MainTable_Rfresh()" clearable>
              </el-input>
            </td>
            <td>仪器大类</td>
            <td>
              <rm-ddl-common @change="instrclassChange" datatype="seccode" kindno="INSTRCLASS"
                v-model="searchObj.instrclass" width="200px"></rm-ddl-common>
            </td>
            <td colspan="2">
              <el-radio-group v-model="searchObj.stopflag">
                <el-radio :label="0" selected @change="MainTable_Rfresh()" size="mini">全部</el-radio>
                <el-radio :label="1" @change="MainTable_Rfresh()" size="mini">停用</el-radio>
                <el-radio :label="2" @change="MainTable_Rfresh()" size="mini">在用</el-radio>
              </el-radio-group>
            </td>
            <td></td>
            <td style="align:right">
            </td>
          </tr>
        </table>
        <div style="width:100%">
          <div style="float:left;width:calc(100% - 300px);font-size:16px;color:blue">
            LIS119报告项目对照外部代码适用于区域LIS模式下共用一套报告项目时的外部代码维护</div>
          <div style="float:left;width:300px">
            <el-button @click="MainTable_Rfresh()" icon="el-icon-search" v-has="'PINQUERY'" type="primary">查询</el-button>
            <el-button @click="MainTable_Save()" icon="el-icon-document" :disabled="!isRegLis">保存</el-button>
            <el-button @click="MainTable_Cancel()" icon="el-icon-close" :disabled="!isRegLis">取消</el-button>
            <el-button @click="btnCopyExcode" v-if="isRegLis">复制外部代码</el-button>
          </div>
        </div>

      </div>
    </template>
    <rm-layout-right splitcolor="white" movingcolor="#00ffff" :splitwidth=5 :fixsize=400>
      <template v-slot:fix>
        <div style="height:100%;border:1px solid #CCC">
          <el-divider content-position="left"><span style="color:blue">外部代码维护</span></el-divider>
          <el-form :disabled="!isRegLis">
            <table>
              <tr>
                <td style="width:90px" align="center">外部代码1</td>
                <td colspan="3">
                  <el-input style="width:140px" @dblclick.native="jbxx_open_externalcodeDialog('1')"
                    placeholder="输入回车|双击选择" v-model="Tab_jbxx_Data_dialog.externalcode1" clearable @clear="clearfun('1')"
                    @keyup.native.enter="getExcodeByEnter('1', Tab_jbxx_Data_dialog.externalcode1)"></el-input>
                </td>
                <td align="left">
                  <span v-if="!!Tab_jbxx_Data_dialog.externalcode1_name"
                    :class="Tab_jbxx_Data_dialog.externalcode1_name.indexOf('未找到') > -1 ? 'redclass' : 'blueclass'">{{ Tab_jbxx_Data_dialog.externalcode1_name }}</span>
                  <span v-else>{{ Tab_jbxx_Data_dialog.externalcode1_name }}</span>
                </td>
              </tr>
              <tr>
                <td style="width:90px" align="center">外部代码2</td>
                <td colspan="3">
                  <el-input style="width:140px" @dblclick.native="jbxx_open_externalcodeDialog('2')"
                    placeholder="输入回车|双击选择" v-model="Tab_jbxx_Data_dialog.externalcode2" clearable @clear="clearfun('2')"
                    @keyup.native.enter="getExcodeByEnter('2', Tab_jbxx_Data_dialog.externalcode2)"></el-input>
                </td>
                <td>
                  <!---{{Tab_jbxx_Data_dialog.externalcode2_name}}--->
                  <span v-if="!!Tab_jbxx_Data_dialog.externalcode2_name"
                    :class="Tab_jbxx_Data_dialog.externalcode2_name.indexOf('未找到') > -1 ? 'redclass' : 'blueclass'">{{ Tab_jbxx_Data_dialog.externalcode2_name }}</span>
                  <span v-else>{{ Tab_jbxx_Data_dialog.externalcode2_name }}</span>
                </td>
              </tr>
              <tr>
                <td style="width:90px" align="center">外部代码3</td>
                <td colspan="3">
                  <el-input style="width:140px" @dblclick.native="jbxx_open_externalcodeDialog('3')"
                    placeholder="输入回车|双击选择" v-model="Tab_jbxx_Data_dialog.externalcode3" clearable @clear="clearfun('3')"
                    @keyup.native.enter="getExcodeByEnter('3', Tab_jbxx_Data_dialog.externalcode3)"></el-input>
                </td>
                <td>
                  <!--- {{Tab_jbxx_Data_dialog.externalcode3_name}}--->
                  <span v-if="!!Tab_jbxx_Data_dialog.externalcode3_name"
                    :class="Tab_jbxx_Data_dialog.externalcode3_name.indexOf('未找到') > -1 ? 'redclass' : 'blueclass'">{{ Tab_jbxx_Data_dialog.externalcode3_name }}</span>
                  <span v-else>{{ Tab_jbxx_Data_dialog.externalcode3_name }}</span>
                </td>
              </tr>
              <tr>
                <td style="width:90px" align="center">外部代码4</td>
                <td colspan="3">
                  <el-input style="width:140px" v-model="Tab_jbxx_Data_dialog.externalcode4" placeholder="输入回车|双击选择"
                    @dblclick.native="jbxx_open_externalcodeDialog('4')" clearable @clear="clearfun('4')"
                    @keyup.native.enter="getExcodeByEnter('4', Tab_jbxx_Data_dialog.externalcode4)">
                  </el-input>
                </td>
                <td>
                  <!--- {{Tab_jbxx_Data_dialog.externalcode4_name}}--->
                  <span v-if="!!Tab_jbxx_Data_dialog.externalcode4_name"
                    :class="Tab_jbxx_Data_dialog.externalcode4_name.indexOf('未找到') > -1 ? 'redclass' : 'blueclass'">{{ Tab_jbxx_Data_dialog.externalcode4_name }}</span>
                  <span v-else>{{ Tab_jbxx_Data_dialog.externalcode4_name }}</span>
                </td>
              </tr>
              <tr>
                <td style="width:90px" align="center">外部代码5</td>
                <td colspan="3">
                  <el-input style="width:140px" v-model="Tab_jbxx_Data_dialog.externalcode5" placeholder="输入回车|双击选择"
                    @dblclick.native="jbxx_open_externalcodeDialog('5')" clearable @clear="clearfun('5')"
                    @keyup.native.enter="getExcodeByEnter('5', Tab_jbxx_Data_dialog.externalcode5)">
                  </el-input>
                </td>
                <td>
                  <!-- {{Tab_jbxx_Data_dialog.externalcode5_name}}-->
                  <span v-if="!!Tab_jbxx_Data_dialog.externalcode5_name"
                    :class="Tab_jbxx_Data_dialog.externalcode5_name.indexOf('未找到') > -1 ? 'redclass' : 'blueclass'">{{ Tab_jbxx_Data_dialog.externalcode5_name }}</span>
                  <span v-else>{{ Tab_jbxx_Data_dialog.externalcode5_name }}</span>
                </td>
              </tr>
              <tr>
                <td colspan="8" style="text-align:left;">
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <div style="font-size:13px;font-weight:800;margin:2px 0px 2px 20px"> 建议：</div><br>
                  <div style="margin:2px 0px 2px 40px">外部代码1 用作HIS系统对照;</div><br>
                  <div style="margin:2px 0px 2px 40px">外部代码2 用作体检系统对照;</div> <br>
                  <div style="margin:2px 0px 2px 40px">外部代码3 用作rmlis4的对照;</div>
                </td>
              </tr>
            </table>
          </el-form>

        </div>
      </template>
      <div style="height:100%;width:100%;background-color:#ddccbb;">
        <vxe-table :data.sync="MainTableData" :loading="MainLoading" :select-config="{ reserve: true }"
          :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row highlight-hover-column
          header-align="center" highlight-hover-row ref="Main_Table" resizable show-overflow size="mini" stripe
          class="mystyle" @current-change="MainTableChange_Event" :row-class-name="GetRowClassName" show-header-overflow>
          <vxe-table-column field="itemclassname" sortable title="项目归类" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="itemcode_en" sortable title="英文缩写" width="58" show-overflow></vxe-table-column>
          <vxe-table-column field="rpt_itemname" sortable title="报告项目名称" width="120" show-overflow></vxe-table-column>
          <vxe-table-column field="rpt_itemcode" sortable title="报告项目代码" width="90" show-overflow></vxe-table-column>
          <vxe-table-column field="ref_text" sortable title="参考值显示" width="80" show-overflow></vxe-table-column>
          <vxe-table-column field="unit" sortable title="单位" width="50" show-overflow></vxe-table-column>
          <vxe-table-column field="rptcode" sortable title="报告单代码" width="80" show-overflow></vxe-table-column>
          <vxe-table-column field="iscalc" sortable title="计算项目" width="70" show-overflow align="center">
            <template v-slot="{ row }">
              <el-checkbox v-model="row.iscalc" disabled true-label="1" false-label="0"></el-checkbox>
            </template>
          </vxe-table-column>
          <vxe-table-column field="calc_formulatext" sortable title="计算公式显示" width="100" show-overflow></vxe-table-column>
          <vxe-table-column field="resulttype_name" sortable title="结果类型" width="78" show-overflow></vxe-table-column>
          <vxe-table-column field="dec_digits_name" sortable title="小数位数" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="instrclass" sortable title="仪器大类" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="germflag_name" sortable title="项目类型" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="mutex_no" sortable title="互斥项目数" width="80" show-overflow></vxe-table-column>
          <vxe-table-column field="transpecimen_no" sortable title="样本转换数" width="80" show-overflow></vxe-table-column>
          <vxe-table-column field="itemname_en" sortable title="英文名称" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="textresultflag_name" sortable title="默认文字结果标志" width="130"
            show-overflow></vxe-table-column>
          <vxe-table-column field="ref_bysex" sortable title="参考值与性别有关" width="130" show-overflow></vxe-table-column>
          <vxe-table-column field="ref_byage" sortable title="参考值与年龄有关" width="130" show-overflow></vxe-table-column>
          <vxe-table-column field="ref_byspecimen" sortable title="参考值与标本有关" width="130" show-overflow></vxe-table-column>
          <vxe-table-column field="ref_l" sortable title="参考低值" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="ref_h" sortable title="参考高值" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="redo_l" sortable title="需复查低值" width="80" show-overflow></vxe-table-column>
          <vxe-table-column field="redo_h" sortable title="需复查高值" width="80" show-overflow></vxe-table-column>
          <vxe-table-column field="autoalert" sortable title="危急值自动上报" width="110" show-overflow align="center">
            <template v-slot="{ row, rowIndex, columnIndex }">
              <div :key="row.rpt_itemcode + rowIndex + columnIndex" v-if="row.autoalert == '1'">
                <el-checkbox checked disabled></el-checkbox>
              </div>
              <div :key="row.rpt_itemcode + rowIndex + columnIndex" v-else>
                <el-checkbox disabled></el-checkbox>
              </div>
            </template>
          </vxe-table-column>
          <vxe-table-column field="price" sortable title="价格" width="50" show-overflow></vxe-table-column>
          <vxe-table-column field="inputcode" sortable title="输入码" width="60" show-overflow></vxe-table-column>
          <vxe-table-column field="externalcode1_name" sortable title="外部代码1" width="80" show-overflow></vxe-table-column>
          <vxe-table-column field="externalcode2_name" sortable title="外部代码2" width="80" show-overflow></vxe-table-column>
          <vxe-table-column field="externalcode3_name" sortable title="外部代码3" width="80" show-overflow></vxe-table-column>
          <vxe-table-column field="mustmatchlast" sortable title="结果不同于上次警告" width="150" show-overflow align="center">
            <template v-slot="{ row, rowIndex, columnIndex }">
              <div :key="row.rpt_itemcode + rowIndex + columnIndex" v-if="row.mustmatchlast == '1'">
                <el-checkbox checked disabled></el-checkbox>
              </div>
              <div :key="row.rpt_itemcode + rowIndex + columnIndex" v-else>
                <el-checkbox disabled></el-checkbox>
              </div>
            </template>
          </vxe-table-column>
          <vxe-table-column field="alertouthours" sortable title="危急值时效" width="83" show-overflow></vxe-table-column>
          <vxe-table-column field="hospcode" sortable title="所属院区" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="stopflag" sortable title="停用" width="50" show-overflow align="center">
            <template v-slot="{ row }">
              <el-checkbox checked disabled v-if="row.stopflag == '1'"></el-checkbox>
              <el-checkbox disabled v-else></el-checkbox>
            </template>
          </vxe-table-column>
          <vxe-table-column field="nostat" sortable title="不统计" width="60" show-overflow align="center">
            <template v-slot="{ row, rowIndex, columnIndex }">
              <div :key="row.rpt_itemcode + rowIndex + columnIndex" v-if="row.nostat == '1'">
                <el-checkbox checked disabled></el-checkbox>
              </div>
              <div :key="row.rpt_itemcode + rowIndex + columnIndex" v-else>
                <el-checkbox disabled></el-checkbox>
              </div>
            </template>
          </vxe-table-column>
          <vxe-table-column field="basename" sortable title="基准代码" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="chklastdays" sortable title="结果和上次比较天数" width="130" show-overflow></vxe-table-column>
          <vxe-table-column field="chklastratio" sortable title="结果和上次比较百分比差" width="160"
            show-overflow></vxe-table-column>
          <vxe-table-column field="chklastabs" sortable title="结果和上次比较数值差" width="150" show-overflow></vxe-table-column>
        </vxe-table>
      </div>
    </rm-layout-right>
    <!--外部代码段-->
    <el-dialog v-el-drag-dialog :append-to-body="true" :visible.sync="jbxx_dialogTable_externalcode"
      :close-on-click-modal="false" @close="jbxx_externalcode_tableData_close" title="外部代码段" width="642px">
      <vxe-toolbar style="margin-bottom:5px;">
        <template v-slot:buttons>
          <el-input class="input-with-select" placeholder="输入查询内容" prefix-icon="el-icon-search" size="small"
            style="max-width:150px;" v-model="jbxx_externalcode_seach" clearable
            @keyup.native.enter="jbxx_externalcode_seachEvent"></el-input>
          <el-button @click="jbxx_externalcode_seachEvent" icon="el-icon-search" size="small" slot="append">查询</el-button>
        </template>
      </vxe-toolbar>
      <vxe-table :data.sync="jbxx_externalcode_tableData" :select-config="{ reserve: true }"
        :sort-config="{ trigger: 'cell' }" @cell-dblclick="jbxx_externalcode_dbclick($event)" border height="300"
        highlight-current-row highlight-hover-column highlight-hover-row resizable show-overflow size="mini" stripe
        header-align="center">
        <vxe-table-column field="rptitemcode" sortable title="项目代码" width="100"></vxe-table-column>
        <vxe-table-column field="rptitemname" sortable title="项目名称" width="100"></vxe-table-column>
        <vxe-table-column field="comment1" sortable title="备用字段1" width="100"></vxe-table-column>
        <vxe-table-column field="comment2" sortable title="备用字段2" width="100"></vxe-table-column>
        <vxe-table-column field="inputcode" sortable title="助记符" width="100"></vxe-table-column>
        <vxe-table-column field="externalmode" sortable title="来源类别" width="100"></vxe-table-column>
      </vxe-table>
    </el-dialog>

    <!--来源医院-->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择外部代码来源医院"
      :visible.sync="CopyExcode.dialogCopyExcode" width="400px">
      <div style="margin:10px 15px 10px 15px">
        <table>
          <tr>
            <td>来源医院：</td>
            <td>
              <rm-ddl-common datatype="hospital" dataname="外部代码来源医院" v-model="CopyExcode.Orihospcode"
                width="200px"></rm-ddl-common>
            </td>
          </tr>
        </table>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="CopyExcodeSave">确 定</el-button>
        <el-button @click="CopyExcode.dialogCopyExcode = false">取 消</el-button>
      </div>
    </el-dialog>
  </rm-layout-top>
</template>
<script type="text/javascript">
export default {
  name: "LIS119",
  data() {
    return {
      searchObj: { rptunitid: "", keystr: "", stopflag: 0, itemclasscode: "", germflag: "", instrclass: "" },
      MainTableData: [],
      MainLoading: false,
      tab_label: "",
      isbis: false,
      Tab_jbxx_Data_dialog: {
        externalcode1: "",
        externalcode1_name: "",
        externalcode2: "",
        externalcode2_name: "",
        externalcode3: "",
        externalcode3_name: "",
        externalcode4: "",
        externalcode4_name: "",
        externalcode5: "",
        externalcode5_name: "",
      },
      jbxx_dialogTable_externalcode: false, //外部代码弹出框控制标志
      selrow: {},
      jbxx_externalcode_seach: "",
      jbxx_externalcode_tableData: [],
      isRegLis: false,
      CopyExcode: {
        dialogCopyExcode: false,
        Orihospcode: "",
      },
    };
  },
  created() {
    this.isbis = this.$tool.checkBis();
    //防止刷新页面导致IsAreaMode被清掉
    this.$ddldata.IsAreaModeFun().then((r) => {
      this.isRegLis = r;
      if (!this.isRegLis) {
        this.$alert("当前模式不是区域LIS模式，不能使用该页面，非区域LIS模式下对照外部代码使用LIS110报告项目维护！", "提示").then(() => {
          this.$pub.closePage(this, "LIS119");
        });
      }
    });

    this.MainTable_Rfresh(); //主表查询
  },
  mounted() { },
  methods: {
    GetRowClassName({ row, rowIndex }) {
      if (row.stopflag == "1") {
        return "rm-disable"; //禁用
      }
    },
    //主表查询
    async MainTable_Rfresh() {
      this.MainLoading = true;
      try {
        const res = await this.$tool.request({
          url: "LIS/LIS1/LIS119",
          method: "post",
          data: {
            action: "lab_rptitem_query",
            ...this.searchObj,
          },
        });
        this.MainTableData = res.RData.Data;

        if (res.RData.Data.length > 0) {
          this.selrow = res.RData.Data[0];
          this.$refs.Main_Table.setCurrentRow(res.RData.Data[0]);
          this.queryRight();
        }
        this.MainLoading = false;
      } catch (e) {
        this.$alert(e, "提示");
        this.MainLoading = false;
      }
    },
    //get_externalmode 外部代码数据获取/刷新方法
    get_externalmode(seachstr, flag) {
      return this.$tool.request({
        url: "LIS/LIS1/LIS119",
        method: "post",
        data: {
          action: "get_externalmode",
          seachstr: seachstr,
          flag: flag,
        },
      });
    },
    //弹出外部代码框
    jbxx_open_externalcodeDialog(flag) {
      this.jbxx_externalcode_seach = "";
      this.jbxx_externalcode_flag = flag;
      let seachstr = this.jbxx_externalcode_seach;

      this.get_externalmode(seachstr, flag)
        .then((res) => {
          this.jbxx_dialogTable_externalcode = true;
          this.jbxx_externalcode_tableData = res.data;
        })
        .catch((e) => {
          this.$alert(e, "提示");
        });
    },
    jbxx_externalcode_tableData_close() {
      this.jbxx_externalcode_seach = "";
      this.jbxx_externalcode_flag = "";
    },
    jbxx_externalcode_seachEvent() {
      let seachstr = this.jbxx_externalcode_seach;
      let flag = this.jbxx_externalcode_flag;
      this.get_externalmode(seachstr, flag)
        .then((res) => {
          this.jbxx_externalcode_tableData = res.data;
        })
        .catch((e) => {
          this.$alert(e, "提示");
        });
    },
    getExcodeByEnter(flag, externalcode) {
      this.jbxx_externalcode_flag = flag;
      this.$tool
        .request({
          url: "LIS/LIS1/LIS119",
          method: "post",
          data: {
            action: "get_externalmode",
            externalcode: externalcode,
            flag: flag,
          },
        })
        .then((res) => {
          if (res.data.length > 0) {
            this.setExternalcode(res.data[0].rptitemcode, res.data[0].rptitemname);
          } else {
            this.setExternalcode(externalcode, "未找到，请检查外部代码！");
          }
        })
        .catch((e) => {
          this.$alert(e, "提示");
        });
    },
    //外部代码 双击选择 赋值事件
    jbxx_externalcode_dbclick(evt) {
      this.setExternalcode(evt.row.rptitemcode, evt.row.rptitemname);
      this.jbxx_dialogTable_externalcode = false;
    },
    setExternalcode(rptitemcode, rptitemname) {
      if (this.jbxx_externalcode_flag === "1") {
        //externalcode1
        this.Tab_jbxx_Data_dialog.externalcode1 = rptitemcode;
        this.Tab_jbxx_Data_dialog.externalcode1_name = rptitemname;
      }
      if (this.jbxx_externalcode_flag === "2") {
        //externalcode2
        this.Tab_jbxx_Data_dialog.externalcode2 = rptitemcode;
        this.Tab_jbxx_Data_dialog.externalcode2_name = rptitemname;
      }
      if (this.jbxx_externalcode_flag === "3") {
        //externalcode3
        this.Tab_jbxx_Data_dialog.externalcode3 = rptitemcode;
        this.Tab_jbxx_Data_dialog.externalcode3_name = rptitemname;
      }
      if (this.jbxx_externalcode_flag === "4") {
        //externalcode4
        this.Tab_jbxx_Data_dialog.externalcode4 = rptitemcode;
        this.Tab_jbxx_Data_dialog.externalcode4_name = rptitemname;
      }
      if (this.jbxx_externalcode_flag === "5") {
        //externalcode5
        this.Tab_jbxx_Data_dialog.externalcode5 = rptitemcode;
        this.Tab_jbxx_Data_dialog.externalcode5_name = rptitemname;
      }
    },
    //获取行数据
    async MainTableChange_Event({ row, rowIndex, column, columnIndex }, event) {
      this.selrow = row;
      this.queryRight();
    },
    queryRight() {
      this.$tool
        .request({
          url: "LIS/LIS1/LIS119",
          method: "post",
          data: {
            action: "queryRight",
            rpt_itemcode: this.selrow.rpt_itemcode,
          },
        })
        .then((res) => {
          if (res.data.length > 0) {
            this.Tab_jbxx_Data_dialog = res.data[0];
          } else {
            this.Tab_jbxx_Data_dialog = [];
          }

          if (res.errcode == "0") {
            this.$alert(res.errmsg, "提示");
          }
        })
        .catch((e) => {
          this.$message.error(e);
        });
    },
    rptitemclassChange(code, name) {
      this.searchObj.itemclasscode = code;
      this.MainTable_Rfresh();
    },
    rptunitChange(code, name) {
      this.searchObj.rptunitid = code;
      this.MainTable_Rfresh();
    },
    germflagChange(code, name) {
      this.searchObj.germflag = code;
      this.MainTable_Rfresh();
    },
    instrclassChange(code, name) {
      this.searchObj.instrclass = code;
      this.MainTable_Rfresh();
    },
    MainTable_Save() {
      this.$tool
        .request({
          url: "LIS/LIS1/LIS119",
          method: "post",
          data: {
            action: "MainTable_Save",
            rpt_itemcode: this.selrow.rpt_itemcode,
            ...this.Tab_jbxx_Data_dialog,
          },
        })
        .then((res) => {
          if (res.errcode == "1") {
            this.$pub.message(this, "保存成功", "success");
          } else {
            this.$alert(res.errmsg, "提示");
          }
        })
        .catch((e) => {
          this.$alert(e, "提示");
        });
    },
    MainTable_Cancel() {
      this.queryRight();
    },
    clearfun(index) {
      if (index == "1") {
        this.Tab_jbxx_Data_dialog.externalcode1 = "";
        this.Tab_jbxx_Data_dialog.externalcode1_name = "";
      } else if (index == "2") {
        this.Tab_jbxx_Data_dialog.externalcode2 = "";
        this.Tab_jbxx_Data_dialog.externalcode2_name = "";
      } else if (index == "3") {
        this.Tab_jbxx_Data_dialog.externalcode3 = "";
        this.Tab_jbxx_Data_dialog.externalcode3_name = "";
      } else if (index == "4") {
        this.Tab_jbxx_Data_dialog.externalcode4 = "";
        this.Tab_jbxx_Data_dialog.externalcode4_name = "";
      } else if (index == "5") {
        this.Tab_jbxx_Data_dialog.externalcode5 = "";
        this.Tab_jbxx_Data_dialog.externalcode5_name = "";
      }
    },
    btnCopyExcode() {
      this.CopyExcode.dialogCopyExcode = true;
      this.CopyExcode.Orihospcode = "";
    },
    //外部代码复制保存
    CopyExcodeSave() {
      if (this.CopyExcode.Orihospcode != "") {
        this.$tool
          .request({
            url: "ucent/liscomm",
            method: "post",
            data: {
              action: "CopyExcodeSave",
              Orihospcode: this.CopyExcode.Orihospcode,
            },
          })
          .then((response) => {
            if (response.errcode == "1") {
              this.$pub.message(this, "所选医院外部代码复制已保存成功,请查看！", "success");
              this.CopyExcode.dialogCopyExcode = false;
            } else {
              this.$alert(response.msg, "提示");
            }
          })
          .catch((e) => {
            this.$alert(e, "出错");
          });
      } else {
        this.$alert("请先选择来源医院！", "提示");
      }
    },
  },
};
</Script>

<style scoped>table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}

/deep/ .el-button.is-disabled {
  border: 0px;
  color: grey;
  background-color: #e6e6e6;
  font-weight: normal;
}

/deep/ .redclass {
  color: red;
}

/deep/ .blueclass {
  color: blue;
}</style>